package structural.decorator;

/**
 * @ClassName: MainTest
 * @Description: 测试类
 * @Author: liu-hao
 * @Date: 2023-04-12 17:05
 * @Version: 1.0
 **/
public class MainTest {

    public static void main(String[] args) {
        // 创建未装饰前组件对象
        Component component = new ConcreteComponent();
        component.operation();
        System.out.println("================");
        // 创建装饰对象A
        Component decoratorA = new ConcreteDecoratorA(component);
        decoratorA.operation(); // 执行装饰器A对象的装饰后的operation()方法
        System.out.println("================");
        // 创建装饰对象B装饰被装饰的对象A
        Component decoratorB = new ConcreteDecoratorB(decoratorA);
        decoratorB.operation(); // 执行装饰器B对象的装饰后的operation()方法
    }
}
